package com.carbon.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carbon.domain.Batch;
import com.carbon.dto.BatchDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 生产批号(Batch)表数据库访问层
 *
 * @author WangFK
 * @since 2023-08-22 20:28:46
 */
@Mapper
public interface BatchMapper extends BaseMapper<Batch> {
    @Select("SELECT\n" +
            "\tt1.product_name,\n" +
            "\tt2.batch_id \n" +
            "FROM\n" +
            "\tbatch t2\n" +
            "\tLEFT JOIN product t1 ON t2.product_id = t1.id \n" +
            "WHERE\n" +
            "\tt2.id = #{batchId}")
    public Batch getProductByBatchId(Integer batchId);
    @Select("SELECT\n" +
            "\tt1.id as productId,\n" +
            "\tt2.id as batchId\n" +
            "FROM\n" +
            "\tbatch t2\n" +
            "\tLEFT JOIN product t1 ON t2.product_id = t1.id \n" +
            "WHERE\n" +
            "\tt2.id = #{batchId}")
    BatchDto getProductIdByBatchId(Integer batchId);
}

